<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微信绑定</title>

    <link rel="stylesheet" href="http://cdn.viptool.cn/lib/bootstrap/3.3.5/css/bootstrap.min.css">
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="http://cdn.viptool.cn/lib/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="http://cdn.viptool.cn/lib/animate.css/2.1.1/animate.min.css" rel="stylesheet">
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
    <link href="http://cdn.viptool.cn/lib/switchery/0.8.2/switchery.min.css" rel="stylesheet"/>
    <link href="http://cdn.viptool.cn/lib/bootstrap-daterangepicker/2.1.25/daterangepicker.min.css" rel="stylesheet">
    <link href="../../resource/lib/imageview/css/imageviewer.css" rel="stylesheet"/>

    <style type="text/css">
        .hr-line-dashed {
            margin: 10px 0;
            height: 1px;
            border-top: 1px dashed #e7eaec;
            background-color: #fff;
            color: #fff;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight tooltip-demo">
    <!--search-->
    <form role="form" id="searchForm" class="search-panel" method="get">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content" style="padding:5px 35px 40px 5px;">
                        <div class="form-inline" style="float:right;">
                            <div class="form-group m-r-sm">
                                <span>绑定微信，可接收新订单信息</span>
                            </div>
                            <span onclick="wxBindList.showQrcode()" class="btn btn-success btn-sm">绑定微信</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->

    <!--list-->
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div class="tabs-container">
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body">
                                <table class="table table-bordered table-hover table-center">
                                    <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>头像</th>
                                        <th>昵称</th>
                                        <th>更新时间</th>
                                        <th>状态</th>
                                        <th>备注</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <!--/*@thymesVar id="row" type="com.shengtang.stagent.data.entity.DeliveryerWxbindPO"*/-->
                                    <tr th:each="row,index:${bindList}">
                                        <td th:text="${index.count}">1</td>
                                        <td><img src="" th:src="${row.headImg}" style="width: 80px;height: 80px;"></td>
                                        <td>
                                            <span th:text="${row.nickName}">昵称</span>
                                        </td>
                                        <td th:text="${#temporals.format(row.updateTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                        <td th:switch="${row.status}">
                                            <th:block th:case="0"><span class="text-warning">禁用</span></th:block>
                                            <th:block th:case="1"><span class="text-info">正常</span></th:block>
                                        </td>
                                        <td>
                                            <span class="color-primary" id="spRemark" th:id="|spRemark_${row.bindId}|" th:text="${row.remark}">备注</span>
                                        </td>
                                        <td>
                                            <button onclick="wxBindList.showBindModal(0)"
                                                    th:onclick="|wxBindList.showBindModal(${row.bindId})|"
                                                    type="button"
                                                    class="btn btn-info btn-xs m-b-none">修改
                                            </button>

                                            <button onclick="wxBindList.deleteBind(0)"
                                                    th:onclick="|wxBindList.deleteBind(${row.bindId})|"
                                                    type="button"
                                                    class="btn btn-danger btn-xs m-b-none">删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="bind_modal" class="modal-content-tag">
    <form id="saveForm">
        <input type="hidden" id="bind_id"/>
        <div class="form-horizontal" style="width: 479px;">
            <div class="form-group form-inline">
                <label class="col-sm-3 control-label">*状态：</label>
                <div class="col-sm-9">
                    <select class="form-control input-sm" id="bind_status">
                        <option value="1">正常</option>
                        <option value="0">禁用</option>
                    </select>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">*备注：</label>
                <div class="col-sm-9">
                    <textarea placeholder="备注" name="bind_remark" id="bind_remark" class="form-control"
                              rows="5" style="height: 80px;width: 300px;"></textarea>
                </div>
            </div>
        </div>
    </form>
</div>

<input type="hidden" id="hidDlyerId" value="0" th:value="${dlyerId}"/>
<!--基础框架js-->
<script src="http://cdn.viptool.cn/lib/jquery/2.2.4/jquery.min.js"></script>
<script src="http://cdn.viptool.cn/lib/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316}"></script>
<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>

<script src="../../resource/js/content.min.js?v=1.0.0" th:src="@{/resource/js/content.min.js?v=1.0.0}"></script>
<script src="../../resource/js/plugins/iCheck/icheck.min.js" th:src="@{/resource/js/plugins/iCheck/icheck.min.js}"></script>
<script src="../../resource/js/plugins/nestable/jquery.nestable.js" th:src="@{/resource/js/plugins/nestable/jquery.nestable.js}"></script>
<script src="../../resource/js/plugins/sweetalert/sweetalert.min.js" th:src="@{/resource/js/plugins/sweetalert/sweetalert.min.js}"></script>
<script src="../../resource/js/plugins/hot/Jquery.util.js" th:src="@{/resource/js/plugins/hot/Jquery.util.js}"></script>


<script src="https://cdn.bootcss.com/Mock.js/1.0.0/mock-min.js"></script>
<script>
    var checkModal = $("#bind_modal").modal("绑定修改", function () {

        wxBindList.saveBind();
    });
    var wxBindList = {
        showBindModal: function (bindId) {
            checkModal.show(function () {
                $("#bind_id").val(bindId);
                $('#bind_remark').val($('#spRemark_'+bindId).html());
            })
        },
        saveBind: function () {
            var param = {bindId: $('#bind_id').val(), status: $('#bind_status').val(), remark: $('#bind_remark').val()};
            hot.ajax('/delivery/wxbind/saveWxBind', param, function (ret) {
                hot.loading.close();
                if (ret.resultCode === 2000) {
                    hot.tip.success('保存成功');
                    setTimeout(function () {
                        window.location.href = window.location.href;
                    }, 800);
                }
                else {
                    hot.tip.error('保存失败');
                }
            });
        },
        showQrcode: function () {
            var dlyerId = $('#hidDlyerId').val();
            var html = '<img src="/qrCode/buildDeliveryBind?deliveryerId='+dlyerId+'" style="width:260px;height:260px"/>';
            layer.alert(html, {
                title: "扫码绑定",
                offset: 200
            });
        },
        deleteBind: function (bindId) {
            hot.confirm("确定要删除？", function () {
                hot.ajax('/delivery/wxbind/deleteWxBind', {bindId: bindId}, function (ret) {
                    hotUtil.loading.close();
                    if (ret.resultCode === 2000) {
                        hot.tip.success('删除成功');
                        setTimeout(function () {
                            window.location.href = window.location.href;
                        }, 800);
                    }
                    else {
                        hot.tip.error('删除失败');
                    }
                });
            });
        }
    };
</script>
</body>
</html>
